package com.bifrost.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;


/**
 * The persistent class for the COUNTRY_AREA database table.
 *
 * @author joewee
 */
@Entity
@Table(name = "COUNTRY_AREA")
@NamedQuery(name = "CountryArea.findAll", query = "SELECT c FROM CountryArea c")
public class CountryArea implements Serializable {

    private static final long serialVersionUID = -5660499794720007611L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(unique = true, nullable = false, name = "ID")
    private Long id;

    @JsonIgnore
    @Column(length = 100, name = "CODE")
    private String code;

    @Column(name = "DEPTH")
    private int depth;

    @Column(length = 100, name = "LATITUDE")
    private String latitude;

    @Column(length = 100, name = "LONGITUDE")
    private String longitude;

    @Column(length = 100, name = "NAME")
    private String name;

    @Column(length = 1, name = "INITIAL")
    private String initial;

    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PARENT_ID", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private CountryArea parent;

    @Column(name = "ROOT_ID")
    private Long rootId;

    @JsonIgnore
    @Column(name = "PARENT_NAME", length = 255)
    private String parentName;

    @Column(length = 10, name = "ZIPCODE")
    private String zipcode;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parent")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<CountryArea> children;

    public CountryArea() {
    }
    public CountryArea(Long id) {
        this.setId(id);
    }
    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public int getDepth() {
        return this.depth;
    }

    public void setDepth(int depth) {
        this.depth = depth;
    }

    public String getLatitude() {
        return this.latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getLongitude() {
        return this.longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public CountryArea getParent() {
        return this.parent;
    }

    public void setParent(CountryArea parent) {
        this.parent = parent;
    }

    public String getParentName() {
        return this.parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public List<CountryArea> getChildren() {
        return children;
    }

    public void setChildren(List<CountryArea> children) {
        this.children = children;
    }

    public String getZipcode() {
        return this.zipcode;
    }

    public void setZipcode(String zipcode) {
        this.zipcode = zipcode;
    }

    public String getInitial() {
        return initial;
    }

    public void setInitial(String initial) {
        this.initial = initial;
    }

    public Long getRootId() {
        return rootId;
    }

    public void setRootId(Long rootId) {
        this.rootId = rootId;
    }
}